package filesystem

import (
	"gitlab.local/DO-module/new-filemanage-module/src/core/fileoperate"
	"gitlab.local/DO-module/new-filemanage-module/src/core/middleware"
	"gitlab.local/DO-module/new-filemanage-module/src/service/filesystem/filefunc"
	"gitlab.local/DO-module/new-filemanage-module/src/service/filesystem/filenavigation"
	"gitlab.local/DO-module/new-filemanage-module/src/service/filesystem/fileshow"
	"gitlab.local/DO-module/new-filemanage-module/src/service/filesystem/filetools"
	"gitlab.local/TerraMaster/tos-modules/database"
	//"gitlab.local/TerraMaster/tos-modules/core/acl"
	"gitlab.local/TerraMaster/tos-modules/core/acl"
	//"gitlab.local/TerraMaster/tos-modules/middleware"
	//"gitlab.local/TerraMaster/tos-modules/network"
	"gitlab.local/DO-module/new-filemanage-module/src/core/tnasonline"
	//"gitlab.local/TerraMaster/tos-modules/tnasonline"
	"gitlab.local/DO-module/new-filemanage-module/src/core/network"
	"gitlab.local/DO-module/new-filemanage-module/src/core/nginx"
	//"gitlab.local/TerraMaster/tos-modules/nginx"
	"sync"
)

type FileStatus struct {
	Share    bool `json:"share"`
	Recently bool `json:"recently"`
	Collect  bool `json:"collect"`
}

type FileSystem struct {
	FileShow  *fileshow.FileShow
	FileTools *filetools.FileTools
	FileNav   *filenavigation.FileNav
	FileFunc  *filefunc.FileFunc
}

var (
	instance *FileSystem
	once     sync.Once
)

type Getter interface {
	FileStatus(uname string) *FileStatus
}

func GetInstance(db database.DbGetter,
	tnasOnline tnasonline.Ctl,
	fOptGetter fileoperate.Getter,
	aclService acl.FolderAttrService,
	ng nginx.PortGetter,
	net network.Networkset,
	m middleware.AuthChecker,
) *FileSystem {
	once.Do(func() {
		instance = &FileSystem{
			FileShow:  fileshow.New(db, aclService, fOptGetter),
			FileTools: filetools.New(fOptGetter),
			FileNav:   filenavigation.New(db, fOptGetter, aclService, ng, net, tnasOnline, m),
			FileFunc:  filefunc.New(db, fOptGetter, aclService),
		}
	})
	return instance
}
